//== SAGITTARIUS ============================================================================

//== FILEDOC =========================================================================

/** @file gmp_set.h
  * @brief Set implementation for mpz_t
  */

//== BEGINNING OF CODE ===============================================================

#ifndef __SAGUTTARUIS__GMP_SET__H_
#define __SAGUTTARUIS__GMP_SET__H_

//== INCLUDES ========================================================================

#include "sagittarius/core/SagittariusCore.h"
#include "sagittarius/gmp/gmpsupport.h"
#include <stddef.h>

#define HASH_COLLISION 1
#define HASH_SUCCESS   0

#ifdef __cplusplus
extern "C" {
#endif

typedef struct {
    uint64 k;
    mpz_t v;
} gmpkv_pair;

//hashkv_pair makegmpkv_pair(void* p, size_t len);

typedef struct {
    uint32 n;
    uint32 depth;
    gmpkv_pair* e;
} gmp_set_bucket;

typedef struct {
    uint64 nbuckets;
    gmp_set_bucket* buckets;
} gmp_set;

int _gmp_set_check(gmp_set* ht, gmpkv_pair e);
int gmp_set_check(gmp_set* ht, mpz_t p);

int _gmp_set_insert(gmp_set* ht, gmpkv_pair e);
int gmp_set_insert(gmp_set* ht, mpz_t p);

gmp_set* gmp_set_rehash(gmp_set* ht, uint32 nbuckets, uint32 depth);

//hashtable* create_hashtable(uint32 nbuckets, uint32 depth);

void gmp_set_destroy(gmp_set* h);

void gmp_set_dumpstate(int fd, gmp_set* h);

#ifdef __cplusplus
}//extern "C"
#endif

#endif
